package com.ifar.audiosdk.model.engine

import com.ifar.audiosdk.common.IfarEventBusTag
import com.orhanobut.logger.Logger
import io.agora.rtc.IRtcEngineEventHandler
import org.simple.eventbus.EventBus

class MyEngineEventHandler : IRtcEngineEventHandler() {

    override fun onFirstRemoteVideoDecoded(uid: Int, width: Int, height: Int, elapsed: Int) {
        EventBus.getDefault().post(uid, IfarEventBusTag.ON_FIRST_REMOTE_VIDEO_DECODED)
    }

    override fun onFirstLocalVideoFrame(width: Int, height: Int, elapsed: Int) {
    }

    override fun onUserJoined(uid: Int, elapsed: Int) {
    }

    override fun onUserOffline(uid: Int, reason: Int) {
        EventBus.getDefault().post(uid, IfarEventBusTag.ON_USER_OFFLINE)
    }

    override fun onUserMuteVideo(uid: Int, muted: Boolean) {

    }

    override fun onRtcStats(stats: RtcStats) {}

    override fun onRemoteVideoStats(stats: RemoteVideoStats) {

    }

    override fun onAudioVolumeIndication(speakerInfos: Array<AudioVolumeInfo>, totalVolume: Int) {

    }

    override fun onLeaveChannel(stats: RtcStats) {}

    override fun onError(error: Int) {
        Logger.e(error.toString().plus(":error"))
    }
}